package com.pds.web.monitor.controller;

import com.pds.common.annotation.Log;
import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.common.enums.BusinessType;
import com.pds.web.monitor.domain.PdsEnvironmentCheck;
import com.pds.web.monitor.service.IPdsEnvironmentCheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/environmentCheck")
public class PdsEnvironmentCheckController extends BaseController {

    @Autowired
    private IPdsEnvironmentCheckService pdsEnvironmentCheckService;

    /**
     * 新增
     *
     * @param pdsEnvironmentCheck
     * @return
     */
//    @Log(title = "监测任务新增监管", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public R<PdsEnvironmentCheck> addCheck(@RequestBody PdsEnvironmentCheck pdsEnvironmentCheck) {
        return R.ok(pdsEnvironmentCheckService.addCheck(pdsEnvironmentCheck));
    }

    /**
     * 删除 -- 根据id
     *
     * @param id
     * @return
     */
//    @Log(title = "监测任务删除监管", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public R<Boolean> deleteCheck(@RequestParam Long id) {
        return R.ok(pdsEnvironmentCheckService.deleteCheck(id));
    }

    /**
     * 查询 -- 分页/条件：userId，taskId，checkResult
     *
     * @param pdsEnvironmentCheck
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo listCheck(PdsEnvironmentCheck pdsEnvironmentCheck) {
        startPage();
        List<PdsEnvironmentCheck> list = pdsEnvironmentCheckService.selectCheckList(pdsEnvironmentCheck);

        return getDataTable(list);
    }
}
